package com.kktestspb.demo.dao;

import com.kktestspb.demo.polo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface UserDaoInt {

    /**
     * 查询所有
     * @return
     */
    @Select("select * from user")
    List<User> getUserList();

    /**
     * 按ID查询
     * @param id
     * @return
     */
    @Select("select * from user where u_id=#{id}")
    User getUserById(@Param("id") String id);

    /**
     * 更新
     * @param user
     * @return
     */
    @Update("update user set u_name=#{uName},u_username=#{uUsername},u_password=#{uPassword},u_sex=#{uSex},u_age=#{uAge}" +
            ",u_tel=#{uTel} where u_id=#{uId}")
    Long updateUser(User user);

    /**
     * 删除
     * @param uid
     * @return
     */
    @Delete("delete from user where u_id=#{id}")
    Long deleteUser(@Param("id") String uid);

    @Insert("insert into user(u_Name,u_username,u_password,u_sex,u_age,u_tel,u_status) values(" +
            "#{uName},#{uUsername},#{uPassword},#{uSex},#{uAge},#{uTel},1)")
    void insertUser(User user);
}
